﻿using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.JDPostBoard.Entity
{
    [Table("Giftcharge", "ID", "JDPB.ConnectionString")]
    public class Giftcharge : Info
    {
        #region SQL column name consts
        public const string SQLCOL_ID = "ID";
        public const string SQLCOL_USERNAME = "Username";
        public const string SQLCOL_USERDISPLAYNAME = "UserDisplayName";
        public const string SQLCOL_USERID = "UserID";
        public const string SQLCOL_DEPARTMENTID = "DepartmentID";
        public const string SQLCOL_DEPARTMENTNAME = "DepartmentName";
        public const string SQLCOL_DEPARTMENTDISPLAYNAME = "DepartmentDisplayName";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Giftcharge() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Giftcharge(int ID)
        {
            this.ID = ID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
            Username = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_USERNAME]);
            UserDisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_USERDISPLAYNAME]);
            UserID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_USERID]);
            DepartmentID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_DEPARTMENTID]);
            DepartmentName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DEPARTMENTNAME]);
            DepartmentDisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DEPARTMENTDISPLAYNAME]);
        }

        #region Properties
        #region Property <int> ID
        [Property("ID", 4, SqlDbType.Int, true, true)]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _ID = int.MinValue;
        #endregion

        #region Property <string> Username
        [Property("Username", 100, SqlDbType.NVarChar, false, false)]
        public string Username
        {
            get { return _Username; }
            set { _Username = value; }
        }
        private string _Username = null;
        #endregion

        #region Property <string> UserDisplayName
        [Property("UserDisplayName", 100, SqlDbType.NVarChar, false, false)]
        public string UserDisplayName
        {
            get { return _UserDisplayName; }
            set { _UserDisplayName = value; }
        }
        private string _UserDisplayName = null;
        #endregion

        #region Property <Guid> UserID
        [Property("UserID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid UserID
        {
            get { return _UserID; }
            set { _UserID = value; }
        }
        private Guid _UserID = Guid.Empty;
        #endregion

        #region Property <Guid> DepartmentID
        [Property("DepartmentID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid DepartmentID
        {
            get { return _DepartmentID; }
            set { _DepartmentID = value; }
        }
        private Guid _DepartmentID = Guid.Empty;
        #endregion

        #region Property <string> DepartmentName
        [Property("DepartmentName", 100, SqlDbType.NVarChar, false, false)]
        public string DepartmentName
        {
            get { return _DepartmentName; }
            set { _DepartmentName = value; }
        }
        private string _DepartmentName = null;
        #endregion

        #region Property <string> DepartmentDisplayName
        [Property("DepartmentDisplayName", 100, SqlDbType.NVarChar, false, false)]
        public string DepartmentDisplayName
        {
            get { return _DepartmentDisplayName; }
            set { _DepartmentDisplayName = value; }
        }
        private string _DepartmentDisplayName = null;
        #endregion
        #endregion


        public bool LoadByIdentity(int ID)
        {
            return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
        }


        public bool DeleteByIdentity()
        {
            return DataAccess.DeleteByIdentity(this);
        }
    }
}
